package OperationSystem.day1206.OutputStream;

import java.io.*;

public class Demo {
    /*
    public static void main(String[] args) throws IOException {
        try (OutputStream os=new FileOutputStream("随便.png")){
            byte[] buffer=new byte[1024];

            while (true){
                //只要还有内容，就不断的写
                int len=fillBuffer(buffer,0,1024);
                if (len==-1){
                    break;
                }
                os.write(buffer,0,len);
            }
        os.flush();
        }
    }

    private static int fillBuffer(byte[] buffer, int i, int i1) {
        return -1;
    }*/
    public static void main(String[] args) throws IOException {
        String[] messages = {};
        try (OutputStream os = new FileOutputStream("随便.txt")) {
            try (Writer writer = new OutputStreamWriter(os, "UTF-8")) {
                try (PrintWriter printWriter = new PrintWriter(writer)) {
                    for (String message : messages) {
                        printWriter.println(message);
                    }
                    printWriter.flush();
                }
            }
        }
    }
}
